package com.xhj.bigfactory.bigFactory.ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * -
 *
 * @author 周沫 @Date 2021-07-31 @Time 19:56
 */
public class ThreadPoolDemo {
  public static void main(String[] args) {
    ExecutorService fixed = Executors.newFixedThreadPool(3);
    ExecutorService single = Executors.newSingleThreadExecutor();
    ExecutorService cached = Executors.newCachedThreadPool();
    for (int i = 0; i < 20; i++) {
      fixed.execute(
          () -> {
            System.out.println(Thread.currentThread().getName() + ": got");
          });
    }
    for (int i = 0; i < 20; i++) {
      single.execute(
          () -> {
            System.out.println(Thread.currentThread().getName() + ": got");
          });
    }
    for (int i = 0; i < 20; i++) {
      cached.execute(
          () -> {
            System.out.println(Thread.currentThread().getName() + ": got");
          });
    }
  }
}
